﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XingFuStudio.Pioneer.Net;
using XingFuStudio.Pioneer.Data;
using XingFuStudio.Pioneer.Entity;
using XingFuStudio.Pioneer.BusinessLogic;
using XingFuStudio.Pioneer.Container.Interface.Event;
using XingFuStudio.Pioneer.Container;

namespace XingFuStudio.Pioneer.WinForms.Demo {
    class Program {
        static void Main(string[] args) {

            List<AccountInfo> accounts = new DbAccount().GetAccounts();

            HttpManager httpManager = new HttpManager();
            LoginManager login = new LoginManager(httpManager);
            login.PringLog += new EventHandler<LogEventArgs>(PringLog);

            foreach (AccountInfo account in accounts) {
                login.Login(account);
            }

            PluginManager pluginManager = PluginManager.GetInstance("Plugins");
            pluginManager.PrintLog += new EventHandler<LogEventArgs>(PringLog);
            pluginManager.Error += new EventHandler<ErrorEventArgs>(Error);

            pluginManager.Initialize();
            pluginManager.Run(accounts);

            Console.ReadLine();

        }

        static void Error(object sender, ErrorEventArgs e) {
            Console.WriteLine(e.Exception.Message);
        }

        static void PringLog(object sender, LogEventArgs e) {
            if (e.IsNewLing) {
                Console.WriteLine(e.LogMessage);
            } else {
                Console.Write(e.LogMessage + " ");
            }
        }
    }
}
